def isHappy(n):
    b=0
    nums=set()
    long=len(nums)
    while n!=1:
        while n!=0:
            a=n%10
            b=b+a*a
            n=n//10
        n=b
        nums.add(b)
        if long==len(nums):
            return False
        long=long+1
        b=0
    return True

print(isHappy(2))